const container=document.querySelector('.seat-container');

let selectedSeat = null; // 记录前一个被选择的座位元素

container.addEventListener('click', e => {
    if (e.target.classList.contains('seat') && !e.target.classList.contains('occupied')) {
        if (selectedSeat) {
            selectedSeat.classList.remove('selected');
        }
        e.target.classList.add('selected');
        selectedSeat = e.target;
    } else if (e.target.classList.contains('selected')) {
        e.target.classList.remove('selected');
        selectedSeat = null;
    }
});